/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Requests.MachineManagement.Components;

import org.virtualbox_3_2.BIOSBootMenuMode;
import org.virtualbox_3_2.FirmwareType;

/**
 * This class represents the BIOS settings of a virtual machine.
 *
 * @author Angel Sanadinov
 */
public class BIOSSettings extends MachineManagementComponent
{
    private FirmwareType firmwareType;      //initial bootstrap firmware type
    private boolean isHpetEnabled;          //High Precision Event Time state
    private boolean runRTCinUTC;            //run RTC in UTC state
    private BIOSBootMenuMode bootMenuMode;  //boot menu mode
    private boolean isACPIEnabled;          //APCI state
    private boolean isIOAPICEnabled;        //IOAPIC state
    private long hostTimeOffset;            //time offset between the host and guest(in ms)

    /**
     * Constructs a BIOS settings object with the specified data.
     *
     * @param firmwareType initial bootstrap firmware type
     * @param hpetEnabled High Precision Event Time state
     * @param runRTCinUTC run RTC in UTC state
     * @param menuMode boot menu mode
     * @param ACPIEnabled APCI state
     * @param IOAPICEnabled IOAPIC state
     * @param hostTimeOffset time offset between the host and guest(in ms)
     */
    public BIOSSettings(FirmwareType firmwareType, boolean hpetEnabled, boolean runRTCinUTC,
            BIOSBootMenuMode menuMode, boolean ACPIEnabled, boolean IOAPICEnabled, long hostTimeOffset)
    {
        this.firmwareType = firmwareType;
        this.isHpetEnabled = hpetEnabled;
        this.runRTCinUTC = runRTCinUTC;
        this.bootMenuMode = menuMode;
        this.isACPIEnabled = ACPIEnabled;
        this.isIOAPICEnabled = IOAPICEnabled;
        this.hostTimeOffset = hostTimeOffset;
    }

    /**
     * Retrieves the firmware type.
     *
     * @return the firmware type
     */
    public FirmwareType getFirmwareType()
    {
        return firmwareType;
    }

    /**
     * Retrieves the HPET state.
     *
     * @return <code>true</code> if HPET is enabled or <code>false</code> if it is not
     */
    public boolean getIsHpetEnabled()
    {
        return isHpetEnabled;
    }

    /**
     * Retrieves the run guest RTC in UTC state.
     *
     * @return <code>true</code> if the guest RTC should run in UTC or <code>false</code>
     *         if it should run in local time
     */
    public boolean getRunRTCinUTC()
    {
        return runRTCinUTC;
    }

    /**
     * Retrieves the boot menu mode.
     *
     * @return the boot menu mode
     */
    public BIOSBootMenuMode getBootMenuMode()
    {
        return bootMenuMode;
    }

    /**
     * Retrieves the ACPI state.
     *
     * @return <code>true</code> if ACPI is enabled or <code>false</code> if it is not
     */
    public boolean getIsACPIEnabled()
    {
        return isACPIEnabled;
    }

    /**
     * Retrieves the IOAPIC state.
     *
     * @return <code>true</code> if IOAPIC is enabled or <code>false</code> if it is not
     */
    public boolean getIsIOAPICEnabled()
    {
        return isIOAPICEnabled;
    }

    /**
     * Retrieves the time offset between the host and the guest.
     *
     * @return the time offset (in ms)
     */
    public long getHostTimeOffset()
    {
        return hostTimeOffset;
    }

    @Override
    public boolean isValid()
    {
        if(firmwareType != null && bootMenuMode != null)
            return true;
        else
            return false;
    }
}
